var paramJson = "";
var uid = sessionStorage.getItem("u_group_no");
$(function () {
	/* 搜索点击事件 */
	$("#searchCancel").on("click", function(){
		//订单类别
		var name = $("#searchInput").val().trim();
		
		//字符串校验
		if(name === ""){
			alert("请输入患者或者医生姓名！")
			return false;
		}
		paramJson = { "actName": "GetIndentM", "rows": "", "page": "", "utype": "5", "uid": 201003, "keyword" : name, "bdate": "", "edate":"", "rand": Math.random() };
		ajaxGet("http://zz.nxk520.com/nethosp/service/nethosp_action.ashx", paramJson, doOk);
	 });
	 
	 /* 订单列表详情点击 */
	 $("#shop_order_list").on("click", ".order-details", function(){
	 	var prescription_id = $(this).attr("data-Pid");
	 	var indent_no = $(this).attr("data-Iid");
	 	
	 	window.location.href = "shop_order_details.html?prescription_id=" + prescription_id + "&indent_no=" + indent_no
	 });
});

/* 请求数据返回 */
function doOk(rstData){
	console.log(rstData);
	if (rstData.code === "1" && rstData.list.length > 0) {
		//生成html片段
		var html = template("shopOrderList",rstData);
		var container = document.getElementById("shop_order_list");
		//将html片段渲染到界面中
		container.innerHTML = html;
	}
	else{
		//生成html片段
		var html = template("noData",rstData);
		var container = document.getElementById("shop_order_list");
		//将html片段渲染到界面中
		container.innerHTML = html;
	}
}
